import request from "../utils/request";
export const login = (data: any) => {
  return request({
    url: `/sys/login`,
    method: 'post',
    data,
  });
};

export const logout = () => {
  return request({
    url: "/sys/logout",
    method: 'post'
  });
};

// 获取用户信息
export const getUserInfo = () => {
  return request({
    url: `/sys/user/info`
  });
};

// 获取可以编辑的用户列表
export const getAuthUser = (params: any) => {
  return request({
    url: `/sys/user/v2/permission/list`,
    params,
  });
};

// 更改用户信息
export const updateUserInfo = (params: any, data: any) => {
  return request({
    url: `/sys/user/v2/update/${params.userId}`,
    data,
    method: 'post',
  });
};

//修改用户密码
export const updatePassword = (data: any) => {
  return request({
    url: `/sys/user/update/password/${data.user_id}`,
    data,
    method: 'put',
  });
};

// 获取创建用户列表
export const getMemberList = (params: any) => {
  return request({
    url: `/sys/user/list`,
    params,
    method: 'get',
  });
};

// 删除用户
export const batchDelet = (params: any) => {
  return request({
    url: `/sys/user/delete/${params.user_id}`,
    method: 'delete',
  });
};


// 创建用户
export const createUser = (data: any) => {
  return request({
    url: `/sys/user/create`,
    data,
    method: 'post',
  });
};

// 获取数据集列表
export const getDataList = (params: any) => {
  return request({
    url: `/data-manage/list-page`,
    params
  })
}

// 获取查询字段列表
export const getDataQuery = () => {
  return request({
    url: `/data-manage/query-params`
  })
}

// 导入
export const importFile = (data: any) => {
  return request({
    url: `/data-manage/import`, 
    data,
    method: 'post'
  })
}

// 下载
export const exportFile = (params: any) => {
  return request({
    url: `/data-manage/export`,
    params,
    responseType: 'blob'
  })
}

// 添加数据
export const addData = (data: any) => {
  return request({
    url: `/data-manage/add`,
    data,
    method: 'post'
  })
}

// 修改数据
export const updateDatabase = (data: any) => {
  return request({
    url: `/data-manage/update`,
    data,
    method: 'post'
  })
}

// 删除数据
export const deleteDatabase = (params: any) => {
  return request({
    url: `/data-manage/delete`,
    params
  })
}